package com.bric.util;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropertiesUtil {
	private static final Logger log=Logger.getLogger(PropertiesUtil.class);
	private static final String defaultConfig="config.properties";
	public static String getValue(String...str) {
		log.info("开始读取"+str[0]+"key的value值");
		if(str.length==1){
			return getValue(str[0],defaultConfig);
		}else{
			return getValue(str[0],str[1]);
		}
	}
	private static String getValue(String key,String fileName){
		Properties pop=new Properties();
		try {
			pop.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName));
			return pop.getProperty(key);
		} catch (IOException e) {
			log.info("读取"+fileName+"properties文件失败");
			return null;
		}
	}
	public static void main(String[] args) {
		System.out.println(getValue("url"));
	}
}
